home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / lcppb.zip / LCPPANS.ZIP / ALPHABET.CPP next >
C/C++ Source or Header  |  1991-07-08  |  953b  |  44 lines

  1. // alphabet.cpp -- switch-statement demonstration
  2.  
  3. #include <iostream.h>
  4. #include <ctype.h>
  5.  
  6. main()
  7. {
  8.   char c;
  9.  
  10.   cout << "Alphabet demonstration\n";
  11.   cout << "\nD-do/while, F-for, W-while? ";
  12.   cin >> c;
  13.  
  14.   switch (toupper(c)) {
  15.     case 'D' :
  16.       cout << "do/while-loop demonstration\n";
  17.       c = 'a';
  18.       do {
  19.         cout << c++;
  20.       } while (c <= 'z');
  21.       break;
  22.     case 'F' :
  23.       cout << "for-loop demonstration\n";
  24.       for (c = 'a'; c <= 'z'; c++)
  25.         cout << c;
  26.       break;
  27.     case 'W' :
  28.       cout << "while-loop demonstration\n";
  29.       c = 'a';
  30.       while (c <= 'z')
  31.         cout << c++;
  32.       break;
  33.     default :
  34.       cout << "Run program again and enter D, F, or W";
  35.   }
  36. }
  37.  
  38.  
  39. // Copyright (c) 1990 by Tom Swan. All rights reserved
  40. // Revision 1.00    Date: 10/24/1990   Time: 08:47 am
  41.  
  42. // Revision 1.01    Date: 07/08/1991   Time: 05:41 pm
  43. // Converted for Borland C++ 2.0
  44.